package com.example.anju.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.anju.entity.House;
import com.example.anju.entity.Result;

import com.example.anju.service.HouseService;

@RestController
@RequestMapping("house")
public class HouseController {
	@Autowired
	private HouseService houseService;

	// 根据house_user_id搜索房源
	@PostMapping("/findHouseByUserId")
	public Result findHouseByUserId(@RequestBody House house) {
		return houseService.findHouseByUserId(house);
	}

	// 根据location搜索房源
	@PostMapping("/findHouseByLocation")
	public Result findHouseByLocation(@RequestBody House house) {
		return houseService.findHouseByLocation(house);
	}

	// 根据address搜索房源
	@PostMapping("/findHouseByAddress")
	public Result findHouseByAddress(@RequestBody House house) {
		return houseService.findHouseByAddress(house);
	}

	// 根据time_type搜索房源
	@PostMapping("/findHouseByTimeType")
	public Result findHouseByTimeType(@RequestBody House house) {
		return houseService.findHouseByTimeType(house);
	}

	// 根据home_type搜索房源
	@PostMapping("/findHouseByHomeType")
	public Result findHouseByHomeType(@RequestBody House house) {
		return houseService.findHouseByHomeType(house);
	}

//	// 根据house_rent搜索房源
//	@PostMapping("/findHouseByHouseRent")
//	public Result findHouseByHouseRent(@RequestBody House house, @RequestBody int min, @RequestBody int max) {
//		return houseService.findHouseByHouseRent(house, min, max);
//	}

	// 发布房源
	@PostMapping("/publishHouse")
	public Result publishHouse(@RequestBody House house) {
		return houseService.publishHouse(house);
	}

	// 修改房源
	@PostMapping("/changeHouseByHouseId")
	public Result changeHouseByHouseId(@RequestBody House house) {
		return houseService.changeHouseByHouseId(house);
	}

}
